package com.fanqwz.kotlinmvvm.data.persist.dao

import android.arch.persistence.room.*
import com.fanqwz.kotlinmvvm.data.persist.UserConstants
import com.fanqwz.kotlinmvvm.data.persist.po.UserPO

/**
 * Created by fanqwz on 2018/3/9.
 */

@Dao
abstract class UserDao {
    @Query("SELECT * FROM ${UserConstants.TABLE_NAME} WHERE code = :code and password = :passwd")
    abstract fun getUser(code: String, passwd: String): UserPO?
    @Query("SELECT * FROM ${UserConstants.TABLE_NAME}")
    abstract fun getUsers(): List<UserPO>
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    abstract fun insertUSer(user:UserPO)
    @Delete
    abstract fun deleteUser(user: UserPO)
    @Update
    abstract fun updateUser(user: UserPO)
}